package com.ahdms.es.bean;

/**
 * @author qinxiang
 * @date 2021-04-19 11:39
 */
public class LdapServerInfo {
    private String address;

    private String searchDn;

    private String[] attrs;

    public LdapServerInfo() {
    }

    public LdapServerInfo(String address, String searchDn,String[] attrs) {
        this.address = address;
        this.searchDn = searchDn;
        this.attrs = attrs;
    }

    public static LdapServerInfo.LdapServerBuilder builder(){
        return new LdapServerInfo.LdapServerBuilder();
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSearchDn() {
        return searchDn;
    }

    public void setSearchDn(String searchDn) {
        this.searchDn = searchDn;
    }

    public String[] getAttrs() {
        return attrs;
    }

    public void setAttrs(String[] attrs) {
        this.attrs = attrs;
    }

    public String getFilter(){
        return this.attrs == null ? null : attrs[0];
    }

    public static class LdapServerBuilder {
        private String address;

        private String searchDn;

        private String[] attrs;

        public LdapServerInfo.LdapServerBuilder address(String address){
            this.address = address;
            return this;
        }

        public LdapServerInfo.LdapServerBuilder searchDn(String searchDn){
            this.searchDn = searchDn;
            return this;
        }

        public LdapServerInfo.LdapServerBuilder attrs(String[] attrs){
            this.attrs = attrs;
            return this;
        }

        public LdapServerInfo build(){
            return new LdapServerInfo(this.address,this.searchDn,this.attrs);
        }
    }
}
